home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / ctimer / introduction < prev    next >
Text File  |  1995-11-05  |  2KB  |  38 lines

  1.  
  2.  
  3.  
  4.                            PROGRAM  TIMERS 
  5.  
  6.  
  7.      Some time ago a program of mine had a bad habit of taking fifty times
  8.   longer to run than it should have done.   None of the profilers that I
  9.   could find worked well enough to tell me what was going on so the first
  10.   CTimer was written (and published in the excellent Australian DiskMag
  11.   MegaDisk).   This was when I first found that there seemed to be no way of
  12.   reading a time value (as opposed to counting down a time interval) to better
  13.   than 20 milliseconds, although the Amiga's trick of adding one to the micro
  14.   -seconds figure each time the clock was accessed within a 20-millisecond
  15.   period made it appear as though genuine microseconds were being produced.
  16.   However Ctimer's 20-millisecond resolution was quite good enough provided
  17.   that short sections of code were run often enough to give an average figure.
  18.   My difficulties were successfully traced to a single line of innocent-looking
  19.   code that an early version of the V2 operating system took exception to. 
  20.  
  21.      Recently a too-sluggish programme re-aroused interest and CTimer1 was
  22.   born.  This read the horizontal and vertical beam position on entry and exit
  23.   from a code section and converted the difference to a time interval.  Direct
  24.   access to the beam counter gave very fast response and minimum dead time,
  25.   with a basic resolution of about 300 nanoseconds.  One problem met was that
  26.   the beam counters had a number of highly idiosyncratic ways of counting.Some
  27.   distinctly dubious fudge factors had to be used to make the results
  28.   meaningful, and hence there must be doubts about accuracy.  
  29.  
  30.      The new V2.0 function ReadEClock offered new possibilities, since this
  31.   returns a figure which can be converted to genuine microseconds.  This is
  32.   used by CTimer2.  The ReadEClock function is fairly slow and dead time is
  33.   high;  resolution is also not (theoretically) as good as CTimer1, but no
  34.   fudges are needed and CTimer2 should be a lot more accurate and reliable.
  35.     
  36.  
  37.            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  38.